<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>RTL SSA Access Lists (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="RTL SSA Access Lists (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="RTL SSA Access Lists (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="RTL-SSA.html" rel="up" title="RTL SSA">
<link href="Changing-RTL-Instructions.html" rel="next" title="Changing RTL Instructions">
<link href="RTL-SSA-Phi-Nodes.html" rel="prev" title="RTL SSA Phi Nodes">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
ul.mark-bullet {list-style-type: disc}
-->
</style>


</head>

<body lang="en">
<div class="subsection-level-extent" id="RTL-SSA-Access-Lists">
<div class="nav-panel">
<p>
Next: <a href="Changing-RTL-Instructions.html" accesskey="n" rel="next">Using the RTL SSA framework to change instructions</a>, Previous: <a href="RTL-SSA-Phi-Nodes.html" accesskey="p" rel="prev">RTL SSA Phi Nodes</a>, Up: <a href="RTL-SSA.html" accesskey="u" rel="up">On-the-Side SSA Form for RTL</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="RTL-SSA-Access-Lists-1"><span>14.21.7 RTL SSA Access Lists<a class="copiable-link" href="#RTL-SSA-Access-Lists-1"> &para;</a></span></h4>

<p>All the definitions of a resource are chained together in reverse postorder.
In general, this list can contain an arbitrary mix of both sets
(<code class="code">rtl_ssa::set_info</code>) and clobbers (<code class="code">rtl_ssa::clobber_info</code>).
However, it is often useful to skip over all intervening clobbers
of a resource in order to find the next set.  The list is constructed
in such a way that this can be done in amortized constant time.
</p>
<p>All uses (<code class="code">rtl_ssa::use_info</code>) of a given set are also chained
together into a list.  This list of uses is divided into three parts:
</p>
<ol class="enumerate">
<li> uses by &ldquo;real&rdquo; nondebug instructions (see <a class="pxref" href="RTL-SSA-Basic-Blocks.html#real-RTL-SSA-insns">real RTL SSA insns</a>)

</li><li> uses by real debug instructions

</li><li> uses by phi nodes (see <a class="pxref" href="RTL-SSA-Phi-Nodes.html">RTL SSA Phi Nodes</a>)
</li></ol>

<p>The first and second parts individually follow reverse postorder.
The third part has no particular order.
</p>
<a class="index-entry-id" id="index-degenerate-phi-node_002c-RTL-SSA"></a>
<p>The last use by a real nondebug instruction always comes earlier in
the reverse postorder than the next definition of the resource (if any).
This means that the accesses follow a linear sequence of the form:
</p>
<ul class="itemize mark-bullet">
<li>first definition of resource R

<ul class="itemize mark-bullet">
<li>first use by a real nondebug instruction of the first definition of resource R

</li><li>&hellip;

</li><li>last use by a real nondebug instruction of the first definition of resource R
</li></ul>

</li><li>second definition of resource R

<ul class="itemize mark-bullet">
<li>first use by a real nondebug instruction of the second definition of resource R

</li><li>&hellip;

</li><li>last use by a real nondebug instruction of the second definition of resource R
</li></ul>

</li><li>&hellip;

</li><li>last definition of resource R

<ul class="itemize mark-bullet">
<li>first use by a real nondebug instruction of the last definition of resource R

</li><li>&hellip;

</li><li>last use by a real nondebug instruction of the last definition of resource R
</li></ul>
</li></ul>

<p>(Note that clobbers never have uses; only sets do.)
</p>
<p>This linear view is easy to achieve when there is only a single definition
of a resource, which is commonly true for pseudo registers.  However,
things are more complex  if code has a structure like the following:
</p>
<div class="example smallexample">
<pre class="example-preformatted">// ebb2, bb2
R = <var class="var">va</var>;        // A
if (...)
  {
    // ebb2, bb3
    use1 (R);  // B
    ...
    R = <var class="var">vc</var>;    // C
  }
else
  {
    // ebb4, bb4
    use2 (R);  // D
  }
</pre></div>

<p>The list of accesses would begin as follows:
</p>
<ul class="itemize mark-bullet">
<li>definition of R by A

<ul class="itemize mark-bullet">
<li>use of A&rsquo;s definition of R by B
</li></ul>

</li><li>definition of R by C
</li></ul>

<p>The next access to R is in D, but the value of R that D uses comes from
A rather than C.
</p>
<p>This is resolved by adding a phi node for <code class="code">ebb4</code>.  All inputs to this
phi node have the same value, which in the example above is A&rsquo;s definition
of R.  In other circumstances, it would not be necessary to create a phi
node when all inputs are equal, so these phi nodes are referred to as
&ldquo;degenerate&rdquo; phi nodes.
</p>
<p>The full list of accesses to R is therefore:
</p>
<ul class="itemize mark-bullet">
<li>definition of R by A

<ul class="itemize mark-bullet">
<li>use of A&rsquo;s definition of R by B
</li></ul>

</li><li>definition of R by C

</li><li>definition of R by ebb4&rsquo;s phi instruction, with the input coming from A

<ul class="itemize mark-bullet">
<li>use of the ebb4&rsquo;s R phi definition of R by B
</li></ul>
</li></ul>

<p>Note that A&rsquo;s definition is also used by ebb4&rsquo;s phi node, but this
use belongs to the third part of the use list described above and
so does not form part of the linear sequence.
</p>
<p>It is possible to &ldquo;look through&rdquo; any degenerate phi to the ultimate
definition using the function <code class="code">look_through_degenerate_phi</code>.
Note that the input to a degenerate phi is never itself provided
by a degenerate phi.
</p>
<p>At present, the SSA form takes this principle one step further
and guarantees that, for any given resource <var class="var">res</var>, one of the
following is true:
</p>
<ul class="itemize mark-bullet">
<li>The resource has a single definition <var class="var">def</var>, which is not a phi node.
Excluding uses of undefined registers, all uses of <var class="var">res</var> by real
nondebug instructions use the value provided by <var class="var">def</var>.

</li><li>Excluding uses of undefined registers, all uses of <var class="var">res</var> use
values provided by definitions that occur earlier in the same
extended basic block.  These definitions might come from phi nodes
or from real instructions.
</li></ul>

</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Changing-RTL-Instructions.html">Using the RTL SSA framework to change instructions</a>, Previous: <a href="RTL-SSA-Phi-Nodes.html">RTL SSA Phi Nodes</a>, Up: <a href="RTL-SSA.html">On-the-Side SSA Form for RTL</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
